﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeanEngine.Entity
{
    public static class IEnumerableMetaColumnExtensions
    {
        public static IEnumerable<MetaColumn> WherePrimaryKey(this IEnumerable<MetaColumn> columnsList)
        {
            return columnsList.Where(c => c.DBColumn.IsPrimaryKey);
        }

        public static IEnumerable<MetaColumn> GetDbGeneratedList(this IEnumerable<MetaColumn> columnsList)
        {
            return columnsList.Where(c => c.DBColumn.IsDbGenerated);
        }

        public static IEnumerable<MetaColumn> WhereNotDbGenerated(this IEnumerable<MetaColumn> columnsList)
        {
            return columnsList.Where(c => !c.DBColumn.IsDbGenerated);
        }

        public static IEnumerable<MetaColumn> GetNotPrimaryKeyOrDbGeneratedList(this IEnumerable<MetaColumn> columnsList)
        {
            return columnsList.Where(c => !c.DBColumn.IsPrimaryKey && !c.DBColumn.IsDbGenerated);
        }
    }
}
